package Game;

public class Class extends Card {
	public static final String CLASS_HUMAN_WARRIOR = "1000";
	public static final String CLASS_HUMAN_KNIGHT = "1001";
	public static final String CLASS_HUMAN_SORCERER = "1002";
	public static final String CLASS_HUMAN_ENCHANTER = "1003";
	public static final String CLASS_HUMAN_ACOLYTE = "1004";
	
	String previousID;
	
	public Class(String _ID) {
		super(_ID);
	}
	
	public void onChangeToClass(Character character) {
		if (ID == CLASS_HUMAN_WARRIOR) {
			// +2 Defense
			Effect effect = new Effect("Warrior", "+2 Defense", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incDefense(2);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incDefense(-2);
				}
			};
			effect.onObtain(character);
			
			// +2 Attack saat menggunakan senjata 1H atau 2H
			int[] actives = {Effect.TRIGGER_EQUIP};
			effect = new Effect("Warrior", "+2 Attack when using one-handed or two-handed weapon",
				Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incAttack(2);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incAttack(-2);
				}
				
				@Override
				public boolean isUnitMetCondition(Unit unit) {
					Character _char = (Character)unit;
					return (_char.isEquip1HWeapon() || _char.isEquip2HWeapon());
				}
			};
			effect.onObtain(character);
		} else if (ID == CLASS_HUMAN_KNIGHT) {
			// +2 Defense
			Effect effect = new Effect("Knight", "+2 Defense", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incDefense(2);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incDefense(-2);
				}
			};
			effect.onObtain(character);
			
			// +2 Block
			effect = new Effect("Knight", "+2 Block", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incBlock(2);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incBlock(-2);
				}
			};
			effect.onObtain(character);
			
			// +1 Attack when using 1H weapon
			int[] actives = {Effect.TRIGGER_EQUIP};
			effect = new Effect("Knight", "+1 Attack when using one-handed weapon", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incAttack(1);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incAttack(-1);
				}
				
				@Override
				public boolean isUnitMetCondition(Unit unit) {
					Character _char = (Character)unit;
					return _char.isEquip1HWeapon();
				}
			};
			effect.onObtain(character);
		} else if (ID == CLASS_HUMAN_SORCERER) {
			// +2 Magic
			Effect effect = new Effect("Sorcerer", "+2 Magic", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incDefense(2);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incDefense(-2);
				}
			};
			effect.onObtain(character);
			
			// +2 Magic saat menggunakan magic berelemen
			int[] actives = {Effect.TRIGGER_ELEMENTAL_MAGIC};
			effect = new Effect("Sorcerer", "+2 Magic when using elemental magic", Effect.TYPE_DAMAGE) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Damage)affectable).baseDamage += 2;
				}
			};
			effect.onObtain(character);
		} else if (ID == CLASS_HUMAN_ENCHANTER) {
			// +1 Magic
			Effect effect = new Effect("Enchanter", "+1 Magic", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incMagic(1);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incMagic(-1);
				}
			};
			effect.onObtain(character);
			
			// +3 MP
			effect = new Effect("Enchanter", "+3 MP", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incMaxMP(3);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incMaxMP(-3);
				}
			};
			effect.onObtain(character);
			
			// NOT DONE 100% kemungkinan berhasil untuk enchanting
		} else if (ID == CLASS_HUMAN_ACOLYTE) {
			// +3 MP
			Effect effect = new Effect("Acolyte", "+3 MP", Effect.TYPE_UNIT) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Unit)affectable).incMaxMP(3);
				}
				
				@Override
				public void onDeactivate(Unit unit) {
					unit.incMaxMP(-3);
				}
			};
			effect.onObtain(character);
			
			int[] triggers = {Effect.TRIGGER_HEALING_MAGIC};
			effect = new Effect("Acolyte", "+50% healing with magic", Effect.TYPE_DAMAGE, triggers) {
				@Override
				public void onActivate(IEffectTarget affectable) {
					((Damage)affectable).damageModifiers.add(1.5);
				}
			};
			effect.onObtain(character);
			
			// NOT DONE -1 MP Cost untuk Skill healing atau magic Holy
		}
	}
	
	public void onChangeFromClass(Character character) {
		
	}
}
